package com.user.basic.analyze.register;

import com.entity.analyze.Register;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

@Mapper
public interface RegisterAnalyzeMapper {
    @Select("SELECT count( create_time ) AS 'count' FROM USER " +
            "WHERE create_time BETWEEN #{startTime} AND #{endTime} " +
            "ORDER BY create_time DESC ")
    List<RegisterAnalyzeEntity> countByCreateTime(Date startTime, Date endTime);

    @Select("SELECT create_time FROM user " +
            "WHERE create_time BETWEEN #{startTime} AND #{endTime} " +
            " ORDER BY create_time DESC")
    List<Date> selectCreateTime(Date startTime, Date endTime);

    @Select("SELECT min(create_time) FROM user ")
    Date minCreateTime();

    @Insert("INSERT INTO register(id, name, total, type, create_time) " +
            "VALUES (#{id}, #{name}, #{total},#{type, javaType=com.entity.analyze.RegisterType, jdbcType=TINYINT," +
            "typeHandler=com.user.basic.analyze.handler.RegisterTypeHandler}," +
            "#{createTime})")
    void save(Register register);
}
